echo "project name $1"
echo "tomcat port  $2"
echo "dubbo port   $3"
echo "git path     $4" 
echo "git branch   $5" 
echo "git profile  $6" 
echo "moduleName   $7" 
echo "finalName    $8" 
#检查项目是否创建
if [ ! -d "/data/project/$1" ]; then
	mkdir /data/project/$1;
	mkdir /data/project/$1/code ;
	mkdir /data/project/$1/source ;
	cp -R /data/project/tomcat /data/project/$1/;
	cp  /data/project/publish.sh /data/project/$1/publish.sh;
	sed -ig "s/@projectName@/$1/" /data/project/$1/publish.sh;
	sed -ig "s/@tomcatPort@/$2/" /data/project/$1/publish.sh;
	sed -ig "s/@dubboPort@/$3/" /data/project/$1/publish.sh;
	sed -ig "s?@gitPath@?$4?" /data/project/$1/publish.sh;
	sed -ig "s/@branch@/$5/" /data/project/$1/publish.sh;
	sed -ig "s/@profile@/$6/" /data/project/$1/publish.sh;
	sed -ig "s/@moduleName@/$7/" /data/project/$1/publish.sh;
	sed -ig "s/@finalName@/$8/" /data/project/$1/publish.sh;
	cd /data/project/$1/source && git clone $4 && cd /data/project/$1/source/`ls /data/project/$1/source` && git checkout origin/$5
	sed -ig "s/@dubboPort@/$3/" /data/project/$1/tomcat/bin/catalina.sh
	sed -ig "s/@tomcatPort@/$2/" /data/project/$1/tomcat/conf/server.xml
    sed -ig "s/@ajpPort@/$(($2-1))/" /data/project/$1/tomcat/conf/server.xml
    sed -ig "s/@shutdownPort@/$(($2-2))/" /data/project/$1/tomcat/conf/server.xml
fi
